package com.katze.boot.system.domain;

import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.converters.date.DateStringConverter;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.katze.boot.common.converter.MenuTypeConverter;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@TableName("sys_menu")
@ExcelIgnoreUnannotated
public class Menu implements Serializable {

    private static final long serialVersionUID = 7187628714679791771L;

    public static final String TYPE_MENU = "0";

    public static final String TYPE_BUTTON = "1";

    public static final String TYPE_WEB = "2";

    @TableId(value = "menu_id", type = IdType.ASSIGN_UUID)
    private String menuId;

    private String parentId;

    @ExcelProperty(value = "标题/名称")
    private String title;

    @ExcelProperty(value = "访问地址")
    private String path;

    @ExcelProperty(value = "对应Vue组件")
    private String component;

    @ExcelProperty(value = "权限")
    private String perms;

    @ExcelProperty(value = "图标")
    private String icon;

    @ExcelProperty(value = "类型", converter = MenuTypeConverter.class)
    private String type;

    @ExcelProperty(value = "序号")
    private Double orderNum;

    @ExcelProperty(value = "参数")
    private String params;

    @ExcelProperty(value = "创建时间", converter  = DateStringConverter.class)
    private Date createTime;

    @ExcelProperty(value = "修改时间", converter  = DateStringConverter.class)
    private Date modifyTime;

    @ExcelProperty(value = "所属模块")
    private String code;

    private transient String createTimeFrom;
    private transient String createTimeTo;

    public Menu(String code) {
        this.code = code;
    }

    public Double getOrderNum() {
        return orderNum == null ? 0.0 : orderNum;
    }
}
